package com.lu.controller;

import com.lu.entity.Floor;
import com.lu.entity.Live;
import com.lu.entity.Student;
import com.lu.service.floor.FloorService;
import org.apache.ibatis.annotations.Delete;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class FloorController {
    private static final Logger log = LoggerFactory.getLogger(FloorController.class);
    @Autowired
    private FloorService floorService;

    //查询楼的所有数据
    @GetMapping("/selectFloorAll")
    public List<Floor> selectFloorAll() {
        return floorService.getFloors();
    }

    //根据id删除数据
    @DeleteMapping("/deleteFloor/{id}")
    public void deleteFloor(@PathVariable Integer id) {
        floorService.deleteFloor(id);
    }

    //根据id查询数据
    @GetMapping("/getFloorById")
    public List<Floor> getFloorById(@RequestParam Integer id) {
        return floorService.getFloorsByid(id);
    }

    //修改楼宇的数据
    @PutMapping("/updateFloor")
    public void updateFloor(@RequestBody Floor floor) {
        floorService.updateFloor(floor);
    }

    //模糊查询
    @PostMapping("/getFloorByBuilName")
    public List<Floor> getFloorByBuilName(@RequestBody Floor floor) {
        return floorService.getFloorsByBuilName(floor);
    }

    //添加入住数据
    @PostMapping("/insertFloorData")
    public void insertFloorData(@RequestBody Floor floor) {
        floorService.insertFloor(floor);
    }
}
